home *** CD-ROM | disk | FTP | other *** search
- ;**************************************************************
- ;
- ; fl_div.asm
- ;
- ; staff
- ;
- ; 06-25-90
- ;
- ; (C) Texas Instruments Inc., 1992
- ;
- ; Refer to the file 'license.txt' included with this
- ; this package for usage and license information.
- ;
- ;**************************************************************
-
-
- .title 'Floating point Division Routine'
-
-
-
- * INPUT FORMAT
- * ============
- * ----------------
- * | ALL 0 OR 1 | SIGN WORD
- * ----------------
- *
- * ----------------
- * | 16 BITS | EXPONENT
- * ----------------
- *
- * ----------------
- * |0| 15 BITS | HIGH PART OF MANTISSA
- * ----------------
- *
- * ----------------
- * |0| 9 BITS |-0-| LOW PART OF MANTISSA
- * ----------------
- *
- * OUTPUT FORMAT
- * =============
- * SAME AS INPUT FORMAT EXCEPT THAT LOW PART OF MANTISSA HAS
- * 16 VALID BITS INSTEAD OF HAVING A ZERO MSB.
- *
-
- ASIGN .set 60h ;Sign, exponent, high and low part of mantissa
- AEXP .set 61h ;of input number A
- AHI .set 62h
- ALO .set 63h
-
- BSIGN .set 64h ;Sign, exponent, high and low part of mantissa
- BEXP .set 65h ;of input number B
- BHI .set 66h
- BLO .set 67h
-
- CSIGN .set 68h ;Sign, exponent, high and low part of mantissa
- CEXP .set 69h ;of the resuting floating point number C
- CHI .set 6Ah
- CLO .set 6Bh
-
- QHI .set 6Ch ;QHIQLO is 32-bit approximate result
- QLO .set 6Dh
- R1 .set 6Ch
- R2 .set 6Dh
- CT .set 6Eh ;16-bit correction term
-
-
- .text
-
- INIT LDP #0
- SETC SXM
- MAR *,AR0 ;for normalization
- LAR AR0,0 ;Reset exponent counter
-
- START LACL ASIGN
- XOR BSIGN
- SACL CSIGN ;storing sign of the result
- LACC AHI,16
- ADDS ALO ;Acc = AHIALO
- BSAR 4 ;to avoid overflow
- RPT #15
- SUBC BHI ;A/BHI:Remainder in AccH,Quotient in AccL
- SACH R1
- SACL QHI
- LACC R1,15
- RPT #15
- SUBC BHI ;R1*2e15/BHI
- SACH R2
- SACL QLO
- LT QHI
- MPY BLO
- PAC ;Acc = QHI*BLO
- RPT #15
- SUBC BHI ;(QHI*BLO)/BHI
- SACL CT ;Save the correction term
- LACL QLO
- ADD QHI,16 ;Acc = QHIQLO
- SUB CT ;Result adjusted by correction term
- SACL CLO
- SACH CHI ;Store the result
- BIT CHI,3
- LACC AEXP
- SUB BEXP
- XC 1,TC
- ADD #1
- CPL #0,CHI
- SACL CEXP
- XC 1,TC
- LACC CLO,16
- XC 2,NTC
- LACC CHI,16
- ADDS CLO
- BCND NOFLOW,LT
- RPT #13
- NORM *+
- RETD
- SACH CHI
- SACL CLO
-
- NOFLOW CLRC SXM
- SFR
- RETD
- SACH CHI
- SACL CLO